﻿// Decompiled with JetBrains decompiler
// Type: Netick.NetickProfiler
// Assembly: Netick, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 6726ECA1-C773-4CF7-8952-E81B30D93B52
// Assembly location: D:\WorkSpaceDemo\UPM\NetickForUnity\Netick\Runtime\Netick.dll
// XML documentation location: D:\WorkSpaceDemo\UPM\NetickForUnity\Netick\Runtime\Netick.xml

using System;
using System.Diagnostics;

#nullable disable
namespace Netick;

public sealed class NetickProfiler
{
  public readonly string Name = "";
  public Action OnStarted;
  public Action OnEnded;
  private Stopwatch _stopWatch;

  public float Time { get; private set; }

  public NetickProfiler(string name)
  {
    this.Name = name;
    this._stopWatch = new Stopwatch();
  }

  public void Begin()
  {
    this._stopWatch.Reset();
    this._stopWatch.Start();
    Action onStarted = this.OnStarted;
    if (onStarted == null)
      return;
    onStarted();
  }

  public void End()
  {
    this.Time = (float) this._stopWatch.Elapsed.TotalMilliseconds;
    this._stopWatch.Stop();
    Action onEnded = this.OnEnded;
    if (onEnded == null)
      return;
    onEnded();
  }
}
